#pragma GCC optimize(2)
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <vector>

using namespace std;
using LL = long long;
const int N = 2e5 + 10;

/*

关键点在于寻找到单调性：f(l, r) <= f(l, r + 1)
f(l, r) = psum[r] - psum[l - 1] - pxor[r] ^ pxor[l - 1]
f(l, r + 1) = psum[r + 1] - psum[l - 1] - pxor[r] ^ pxor[l - 1] ^ q[r + 1]
f(l, r + 1) - f(l, r) = q[r + 1] - (pxor[r] ^ pxor[l - 1] - pxor[r] ^ pxor[l - 1] ^ q[r + 1]) >= 0

在对每一个l找到当f(l, r)最大时，r的最小值
求出答案

*/

LL n, q, l1, r1;
LL R[N], maxv[N];
LL psum[N], pxor[N];

LL getv(int l, int r){
    return psum[r] - psum[l - 1] - (pxor[r] ^ pxor[l - 1]);
}

int bsearch(int fo){
    LL t = getv(fo, n);
    int l = fo, r = n;
    while(l < r){
        int mid = l + r >> 1;
        if(getv(fo, mid) < t){
            l = mid + 1;
        }else{
            r = mid;
        } 
        //求 >= t 的最小值，也就是最小的范围

    }
    maxv[fo] = getv(fo,  l);
    return l;
}

void solve(){
    cin >> n >> q;

    for(LL i = 1, x; i <= n; i ++){
        cin >> x;
        psum[i] = psum[i - 1] + x;
        pxor[i] = pxor[i - 1] ^ x;
    }
    cin >> l1 >> r1;

    // for(int i = 1; i <= n; i ++) cout << pxor[i] << " ";
    // cout << '\n';

    for(int i = 1; i <= n; i ++){
        R[i] = bsearch(i);
    }

   // cout << getv(1, 3) << " " << getv(2, 3) << '\n';
    LL res = -10000000, idx = -1;
    for(int i = 1; i <= n; i ++){
        if(maxv[i] > res){
            res = maxv[i];
            idx = i;
        }else if(maxv[i] == res && R[idx] - idx > R[i] - i){
            idx = i;
        }
    }

    cout << idx << " " << R[idx] << '\n';
}

int main(){
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int T;
    cin >> T;
    while(T--){
        solve();
    }
    return 0;
}